package com.algrithom.find;

import com.algrithom.pointer.Solution1;

/**
 * 162. 寻找峰值
 */
public class Solution5 {
    public static void main(String[] args){
        int[] height = new int[]{1,2,3,1};
        Solution5 solution5 = new Solution5();
        System.out.println(solution5.findPeakElement(height));
    }

    public int findPeakElement(int[] nums) {
        return search(nums,0,nums.length - 1);
    }

    private int search(int[] nums,int left,int right) {
        if (left == right) {
            return left;
        }
        int mid = (left + right) / 2;
        if (nums[mid] > nums[mid + 1]) {
            return search(nums,left,mid);
        }
        return search(nums,mid + 1,right);
    }
}
